﻿var MCP = MCP || {};

MCP.Settings = MCP.Settings || (function () {
	var initializeSettingsPage = function (settings) {
		//$("div.first-name input").val(settings.FirstName);
		//$("div.last-name input").val(settings.LastName);
		//$("div.month-income input").val(settings.MonthIncome);
		//$("div.min-balance input").val(settings.MinBalance);

		$('button.helper').click(function () {
			$(this).prev().val("");
		});
	};
	var saveChanges = function () {
		var settingsToSave = {
			FirstName: $("div.first-name input").val(),
			LastName: $("div.last-name input").val(),
			MonthIncome: $("div.month-income input").val(),
			MinBalance: $("div.min-balance input").val(),
			TariffName: ''
		};
		$.ajax({
			type: "POST",
			data: settingsToSave,
			//dataType: 'json',
			//contentType: 'application/json; charset=utf-8',
			url: "/ChecksList/SaveSettingsAjax",
			success: function (data, textStatus, jqXHR) {
				window.location.href = "/UserMenu/UserMenu";
			},
			error: function(XMLHttpRequest, textStatus, errorThrown) {
				alert('Error!\r\n' + XMLHttpRequest.statusText);
			}
		});

		
	};

	return {
		Save: saveChanges,
		Initialize: initializeSettingsPage
	};
})()